const api = require("../config/api.js");
const util = require("./util.js");

// 人机对战---申请题目
function getGeneralQuestion() {
    return new Promise(function (resolve, reject) {
        util.request(api.generalQuestion+ (wx.getStorageSync('gameInfo')? wx.getStorageSync('gameInfo').lv: 1 ), {}, "GET").then(res => {
                console.log(res)
                wx.setStorageSync('question', res.data);
                resolve(res)
            }
        ).catch(err => {
            reject(err)
        })
    })
}

function getPkQuestion() {
    return new Promise(function (resolve, reject) {
        util.request(api.pkQuestion, {}, "GET").then(res => {
                console.log(res)
                wx.setStorageSync('question', res);
                resolve(res)
            }
        ).catch(err => {
            reject(err)
        })
    })
}

module.exports = {
    getGeneralQuestion,
    getPkQuestion
}